<?php
class Slog_View_Helper_Link extends Slog_View_Helper 
{
	public function run($params)
	{
		$controller = array_shift($params);
		$action = array_shift($params);
		
		$url = Slog::request()->getBaseURI();
		
		if (Slog::config()->getString('rewrite')) {
			// modo rewrite
			$url .= '/';
		} else {
			// modo ?q=
			$url .= '?q=';
		}
		
		if ($controller) {
			$url .= $controller;
			if ($action) {
				$url .= '/' . $action;
				if (count($params) > 0) {
					$url .= '/' . implode('/', $params);
				}
			}
		}
		
		return $url;
	}
}